Skip to content

fix(serverless): redact env values in debug response logs - #92

Open
Ryank90 wants to merge 2 commits into
feat/runserv-504from
fix/env-redact-stack
Open

fix(serverless): redact env values in debug response logs#92
Ryank90 wants to merge 2 commits into
feat/runserv-504from
fix/env-redact-stack

Conversation

@Ryank90

@Ryank90 Ryank90 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Route serverless control-plane --debug logging through a shared helper that redacts JSON "value" fields on 2xx/3xx response bodies so plaintext env vars are not persisted in logs.
  • Error bodies (problem details) are still logged as returned.
  • Stacked on feat/runserv-504 so UpdateDeployment (apps scale) is covered as well.

Test plan

  • go test -race ./internal/api/serverless/
  • Confirm --debug on runware serverless apps env list / env set shows [redacted] for values
  • Confirm a 4xx problem-details body is still visible under --debug

Made with Cursor

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. To trigger a review, include coderabbit-review in the PR description. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0c275c89-dbba-4359-a518-5cb922f62e19

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes --debug response logging for the serverless control-plane client behind a shared helper that redacts JSON "value" fields on successful (2xx/3xx) responses, preventing plaintext env var / secret values from being persisted in debug logs.

Changes:

  • Replaces per-callsite debug logging in serverless API methods with a shared Client.logResponse(...) helper.
  • Adds JSON redaction logic that recursively replaces "value" fields with "[redacted]" for success responses while leaving error bodies unchanged.
  • Introduces unit tests covering redaction behavior and success-vs-error logging behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal/api/serverless/secrets.go Routes secrets endpoints through the shared response logger (now includes body logging).
internal/api/serverless/env.go Routes env var endpoints through the shared response logger so "value" fields are redacted on success.
internal/api/serverless/client.go Routes additional control-plane endpoints through the shared response logger for consistent debug output.
internal/api/serverless/log.go Implements centralized debug response logging and recursive JSON "value" redaction for success responses.
internal/api/serverless/log_test.go Adds tests validating redaction behavior and the success/error logging split.
Suppressed comments (3)

internal/api/serverless/secrets.go:83

  • This now logs the full /v1/secrets response body under --debug. Although secret values are not returned, the response can include user-provided metadata (see gen.Secret.Metadata) which may contain sensitive data and is not redacted by redactJSONValues (it only redacts the key "value"). Consider keeping the previous behavior (log status/path only) for secrets endpoints by not passing the response body here.
	c.logResponse(ctx, "/v1/secrets", resp.StatusCode(), resp.Body)

internal/api/serverless/secrets.go:152

  • This now logs the full /v1/secrets/{name} response body under --debug. Secret responses can include user-provided metadata which is not redacted by redactJSONValues (it only redacts the key "value"), so sensitive metadata could end up in logs. Consider not logging bodies for secrets endpoints.
	c.logResponse(ctx, "/v1/secrets/"+name, resp.StatusCode(), resp.Body)

internal/api/serverless/secrets.go:218

  • This logs the /v1/deployments/{id}/secrets response body under --debug. While values are not returned, attached secret records may still include user-provided metadata via the underlying Secret, which isn't redacted by redactJSONValues. If the goal is specifically to avoid persisting secret-related data in logs, consider omitting bodies for secrets endpoints.
	c.logResponse(ctx, "/v1/deployments/"+deploymentID+"/secrets", resp.StatusCode(), resp.Body)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/api/serverless/secrets.go Outdated
Comment thread internal/api/serverless/secrets.go Outdated
Comment thread internal/api/serverless/secrets.go Outdated
Comment thread internal/api/serverless/secrets.go Outdated
Ryank90 and others added 2 commits August 18, 2026 21:52
Plaintext environment-variable values were written to --debug logs via response bodies. Route control-plane debug logging through a helper that redacts JSON "value" fields on 2xx/3xx responses.

Co-authored-by: Cursor <cursoragent@cursor.com>
Secret responses can include opaque user metadata that is not covered by value redaction. Log path and status only for secrets endpoints.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Ryank90
Ryank90 force-pushed the fix/env-redact-stack branch from 1726b44 to 7ec365d Compare August 18, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants